import { _ as _export_sfc } from './_plugin-vue_export-helper-DgDhiqFL.js';
import { c as createElementBlock, o as openBlock, R as renderSlot, N as isDark, d as defineComponent, x as createBlock, y as resolveDynamicComponent, A as h, e as computed, q as withCtx, n as normalizeStyle, h as unref, j as normalizeClass, a as createBaseVNode, t as toDisplayString, m as usePayloadStore, g as createCommentVNode, F as Fragment, a8 as toggleDark, r as renderList, i as createVNode } from './index-_j_6erbz.js';

/* unplugin-vue-components disabled */const _sfc_main$5 = {};

const _hoisted_1$4 = { class: "h-[calc(100vh-55px)]" };

function _sfc_render(_ctx, _cache) {
  return (openBlock(), createElementBlock("div", _hoisted_1$4, [
    renderSlot(_ctx.$slots, "default")
  ]))
}
const __unplugin_components_3 = /*#__PURE__*/_export_sfc(_sfc_main$5, [['render',_sfc_render]]);
/* Injected with object hook! */

const predefinedColorMap = {
  error: 0,
  client: 60,
  bailout: -1,
  ssr: 270,
  vite: 250,
  vite1: 240,
  vite2: 120,
  virtual: 140
};
function getHashColorFromString(name, opacity = 1) {
  if (predefinedColorMap[name])
    return getHsla(predefinedColorMap[name], opacity);
  let hash = 0;
  for (let i = 0; i < name.length; i++)
    hash = name.charCodeAt(i) + ((hash << 5) - hash);
  const hue = hash % 360;
  return getHsla(hue, opacity);
}
function getHsla(hue, opacity = 1) {
  const saturation = hue === -1 ? 0 : isDark.value ? 50 : 100;
  const lightness = isDark.value ? 60 : 20;
  return `hsla(${hue}, ${saturation}%, ${lightness}%, ${opacity})`;
}
function getPluginColor(name, opacity = 1) {
  if (predefinedColorMap[name]) {
    const color = predefinedColorMap[name];
    if (typeof color === "number") {
      return getHsla(color, opacity);
    } else {
      if (opacity === 1)
        return color;
      const opacityHex = Math.floor(opacity * 255).toString(16).padStart(2, "0");
      return color + opacityHex;
    }
  }
  return getHashColorFromString(name, opacity);
}

/* Injected with object hook! */

const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  __name: "PluginName",
  props: {
    name: {},
    compact: { type: Boolean },
    colored: { type: Boolean },
    hide: { type: Boolean }
  },
  setup(__props) {
    const props = __props;
    const startsGeneric = [
      "__load__",
      "vite-plugin-",
      "vite-",
      "rollup-plugin-",
      "rollup-",
      "unplugin-"
    ];
    const startCompact = [
      ...startsGeneric,
      "vite:"
    ];
    function render() {
      const starts = props.compact ? startCompact : startsGeneric;
      for (const s of starts) {
        if (props.name.startsWith(s)) {
          if (props.compact)
            return h("span", props.name.slice(s.length));
          return h("span", [
            h("span", { class: "op50" }, s),
            h("span", props.name.slice(s.length))
          ]);
        }
      }
      const parts = props.name.split(":");
      if (parts.length > 1) {
        return h("span", [
          h("span", { style: { color: getHashColorFromString(parts[0]) } }, `${parts[0]}:`),
          h("span", parts.slice(1).join(":"))
        ]);
      }
      return h("span", props.name);
    }
    return (_ctx, _cache) => {
      return openBlock(), createBlock(resolveDynamicComponent(render));
    };
  }
});

/* Injected with object hook! */

const _hoisted_1$3 = ["textContent"];
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "Badge",
  props: {
    text: {},
    color: { type: [Boolean, Number], default: true },
    as: {},
    size: {}
  },
  setup(__props) {
    const props = __props;
    const style = computed(() => {
      if (!props.text || props.color === false)
        return {};
      return {
        color: typeof props.color === "number" ? getHsla(props.color) : getHashColorFromString(props.text),
        background: typeof props.color === "number" ? getHsla(props.color, 0.1) : getHashColorFromString(props.text, 0.1)
      };
    });
    const sizeClasses = computed(() => {
      switch (props.size || "sm") {
        case "sm":
          return "px-1.5 text-11px leading-1.6em";
      }
      return "";
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(resolveDynamicComponent(_ctx.as || "span"), {
        "ws-nowrap": "",
        rounded: "",
        class: normalizeClass(unref(sizeClasses)),
        style: normalizeStyle(unref(style))
      }, {
        default: withCtx(() => [
          renderSlot(_ctx.$slots, "default", {}, () => [
            createBaseVNode("span", {
              textContent: toDisplayString(props.text)
            }, null, 8, _hoisted_1$3)
          ])
        ]),
        _: 3
      }, 8, ["class", "style"]);
    };
  }
});

/* Injected with object hook! */

const _hoisted_1$2 = {
  "h-54px": "",
  flex: "~ none gap-2",
  border: "b main",
  "pl-4": "",
  "pr-4": "",
  "font-light": "",
  "children:my-auto": ""
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "NavBar",
  setup(__props) {
    const payload = usePayloadStore();
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("nav", _hoisted_1$2, [
        renderSlot(_ctx.$slots, "default"),
        renderSlot(_ctx.$slots, "actions", {}, () => [
          !unref(payload).metadata.embedded ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
            _cache[2] || (_cache[2] = createBaseVNode("div", {
              mx1: "",
              "h-full": "",
              "w-0": "",
              border: "r main"
            }, null, -1)),
            _cache[3] || (_cache[3] = createBaseVNode("a", {
              "text-lg": "",
              "icon-btn": "",
              href: "https://github.com/antfu/vite-plugin-inspect",
              target: "_blank"
            }, [
              createBaseVNode("div", { "i-carbon-logo-github": "" })
            ], -1)),
            createBaseVNode("button", {
              class: "text-lg icon-btn",
              title: "Toggle Dark Mode",
              onClick: _cache[0] || (_cache[0] = ($event) => unref(toggleDark)())
            }, _cache[1] || (_cache[1] = [
              createBaseVNode("span", {
                "i-carbon-sun": "",
                "dark:i-carbon-moon": ""
              }, null, -1)
            ]))
          ], 64)) : createCommentVNode("", true)
        ])
      ]);
    };
  }
});

/* Injected with object hook! */

const _hoisted_1$1 = {
  flex: "~ gap-1 items-center",
  border: "~ subtle rounded",
  "bg-subtle": "",
  p1: ""
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "SegmentControl",
  props: {
    options: {},
    modelValue: {}
  },
  emits: ["update:modelValue"],
  setup(__props) {
    return (_ctx, _cache) => {
      const _component_Badge = _sfc_main$3;
      return openBlock(), createElementBlock("div", _hoisted_1$1, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option) => {
          return openBlock(), createBlock(_component_Badge, {
            key: option.value,
            class: normalizeClass(["px-2 py-1 text-xs font-mono", option.value === _ctx.modelValue ? "" : "op50"]),
            color: option.value === _ctx.modelValue,
            "aria-pressed": option.value === _ctx.modelValue,
            size: "none",
            text: option.label,
            as: "button",
            onClick: ($event) => _ctx.$emit("update:modelValue", option.value)
          }, null, 8, ["class", "color", "aria-pressed", "text", "onClick"]);
        }), 128))
      ]);
    };
  }
});

/* Injected with object hook! */

const _hoisted_1 = { flex: "~ gap-2" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "QuerySelector",
  setup(__props) {
    const payload = usePayloadStore();
    return (_ctx, _cache) => {
      const _component_SegmentControl = _sfc_main$1;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        unref(payload).metadata.instances.length > 1 ? (openBlock(), createBlock(_component_SegmentControl, {
          key: 0,
          modelValue: unref(payload).query.vite,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(payload).query.vite = $event),
          options: unref(payload).metadata.instances.map((i) => ({ label: i.vite, value: i.vite }))
        }, null, 8, ["modelValue", "options"])) : createCommentVNode("", true),
        createVNode(_component_SegmentControl, {
          modelValue: unref(payload).query.env,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(payload).query.env = $event),
          options: unref(payload).instance.environments.map((i) => ({ label: i, value: i }))
        }, null, 8, ["modelValue", "options"])
      ]);
    };
  }
});

/* Injected with object hook! */

export { _sfc_main$2 as _, __unplugin_components_3 as a, _sfc_main as b, _sfc_main$1 as c, _sfc_main$4 as d, _sfc_main$3 as e, getPluginColor as g };
